//
//  XGLPublishUIManager.swift
//  XGamesLive
//
//  Created by ios on 2024/5/21.
//

import Foundation


class XGLPublishUIManager{
    
    static func creatInputTextItemView(title: String,inputText: UITextField,rightItem: UIView? = nil)->UIView{
        let view = UIView()
        let titleText = UILabel().then { make in
            make.text = title
            make.textColor = UIColor.white
            make.font = UIFont.pingfangSC_Regular(fontSize: 16.0)
        }
        let inputContentView = UIView().then { make in
            make.backgroundColor = UIColor.hexColor("#001310")
            make.layerCornerRadius = 12.0
        }
        view.addSubviews([titleText,inputContentView])
        if let itemView = rightItem {
            inputContentView.addSubview(itemView)
            itemView.snp.makeConstraints { make in
                make.centerY.equalToSuperview()
                make.right.equalTo(-25)
                make.height.equalTo(10.0)
                make.width.equalTo(19.0)
            }
        }
        inputContentView.addSubview(inputText)
        inputText.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.left.equalTo(20.0)
            make.height.equalTo(30.0)
        }
        titleText.snp.makeConstraints { make in
            make.left.top.equalToSuperview()
        }
        inputContentView.snp.makeConstraints { make in
            make.width.centerX.equalToSuperview()
            make.top.equalTo(titleText.snp.bottom).offset(16.0)
            make.height.equalTo(59.0)
        }
        view.snp.makeConstraints { make in
            make.bottom.equalTo(inputContentView)
        }
        
        return view
    }
    
    static func createCommonItemView(title: String,commonView: UIView)->UIView{
        let view = UIView()
        let titleText = UILabel().then { make in
            make.text = title
            make.textColor = UIColor.white
            make.font = UIFont.pingfangSC_Regular(fontSize: 16.0)
        }
        view.addSubviews([titleText,commonView])
        titleText.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.equalTo(15.0)
        }
        commonView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalTo(titleText.snp.bottom).offset(12.0)
            make.centerX.equalToSuperview()
        }
        view.snp.makeConstraints { make in
            make.bottom.equalTo(commonView.snp.bottom).offset(4.0)
        }
        return view
    }
    
    static func createButtonItem(title: String,icon: String,button: UIButton)->UIView{
        let view = UIView()
        let titleText = UILabel().then { make in
            make.text = title
            make.textColor = UIColor.white
            make.font = UIFont.pingfangSC_Regular(fontSize: 14.0)
        }
        let iconView = UIImageView(image: imageWithName(icon))
        
        view.addSubviews([iconView,titleText,button])
        iconView.snp.makeConstraints { make in
            make.centerX.width.top.equalToSuperview()
            make.height.equalTo(iconView.width)
        }
        titleText.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(iconView.snp.bottom).offset(12.0)
        }
        button.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        view.snp.makeConstraints { make in
            make.bottom.equalTo(titleText.snp.bottom)
        }
        
        return view
    }
    
    static func createUploadIocn()->UIImage{
        let view = UIView().then { make in
            make.backgroundColor = UIColor.hexColor("#001310").withAlphaComponent(0.5)
            make.layerCornerRadius = 14.0
        }
        let centerView = UIImageView(image: imageWithName("icon_xgl_image_pick_add"))
        view.addSubview(centerView)
        centerView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.height.equalTo(18.0)
        }
        view.snp.makeConstraints { make in
            make.width.equalTo(163.0)
            make.height.equalTo(117.0)
        }
        view.layoutIfNeeded()
        return view.getImage()
    }
}
